using System;
using System.Drawing;
using System.Windows.Forms;

namespace HuaRongDaoGame.Forms
{
    /// <summary>
    /// Help Form
    /// </summary>
    public partial class HelpForm : Form
    {
        public HelpForm()
        {
            InitializeForm();
        }

        /// <summary>
        /// Initialize form
        /// </summary>
        private void InitializeForm()
        {
            this.Text = "Game Help";
            this.StartPosition = FormStartPosition.CenterParent;
            this.FormBorderStyle = FormBorderStyle.FixedDialog;
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.Size = new Size(600, 500);
            this.BackColor = Color.LightGray;

            CreateControls();
        }

        /// <summary>
        /// Create controls
        /// </summary>
        private void CreateControls()
        {
            // Title label
            var titleLabel = new Label
            {
                Text = "HuaRongDao Game Help",
                Font = new Font("Microsoft YaHei", 16, FontStyle.Bold),
                ForeColor = Color.DarkBlue,
                TextAlign = ContentAlignment.MiddleCenter,
                Size = new Size(500, 30),
                Location = new Point(50, 20)
            };

            // Create tab control
            var tabControl = new TabControl
            {
                Location = new Point(30, 60),
                Size = new Size(540, 350),
                Font = new Font("Microsoft YaHei", 9)
            };

            // Game rules tab
            var rulesTab = new TabPage("Game Rules");
            var rulesTextBox = new TextBox
            {
                Multiline = true,
                ReadOnly = true,
                ScrollBars = ScrollBars.Vertical,
                Font = new Font("Microsoft YaHei", 9),
                Location = new Point(10, 10),
                Size = new Size(500, 280),
                Text = GetGameRulesText()
            };
            rulesTab.Controls.Add(rulesTextBox);

            // Controls guide tab
            var controlsTab = new TabPage("Controls Guide");
            var controlsTextBox = new TextBox
            {
                Multiline = true,
                ReadOnly = true,
                ScrollBars = ScrollBars.Vertical,
                Font = new Font("Microsoft YaHei", 9),
                Location = new Point(10, 10),
                Size = new Size(500, 280),
                Text = GetControlsText()
            };
            controlsTab.Controls.Add(controlsTextBox);

            // FAQ tab
            var faqTab = new TabPage("FAQ");
            var faqTextBox = new TextBox
            {
                Multiline = true,
                ReadOnly = true,
                ScrollBars = ScrollBars.Vertical,
                Font = new Font("Microsoft YaHei", 9),
                Location = new Point(10, 10),
                Size = new Size(500, 280),
                Text = GetFAQText()
            };
            faqTab.Controls.Add(faqTextBox);

            // About tab
            var aboutTab = new TabPage("About");
            var aboutTextBox = new TextBox
            {
                Multiline = true,
                ReadOnly = true,
                ScrollBars = ScrollBars.Vertical,
                Font = new Font("Microsoft YaHei", 9),
                Location = new Point(10, 10),
                Size = new Size(500, 280),
                Text = GetAboutText()
            };
            aboutTab.Controls.Add(aboutTextBox);

            // Add tabs to control
            tabControl.TabPages.Add(rulesTab);
            tabControl.TabPages.Add(controlsTab);
            tabControl.TabPages.Add(faqTab);
            tabControl.TabPages.Add(aboutTab);

            // Close button
            var closeButton = new Button
            {
                Text = "Close",
                Font = new Font("Microsoft YaHei", 10),
                Size = new Size(80, 30),
                Location = new Point(250, 420),
                BackColor = Color.LightBlue
            };
            closeButton.Click += (sender, e) => this.Close();

            // Add controls to form
            this.Controls.Add(titleLabel);
            this.Controls.Add(tabControl);
            this.Controls.Add(closeButton);
        }

        /// <summary>
        /// Get game rules text
        /// </summary>
        private string GetGameRulesText()
        {
            return @"HuaRongDao Game Rules:

1. Game Objective:
   Move Cao Cao (the largest block) to the exit position at the bottom of the board.

2. Game Rules:
   - Blocks can only move horizontally or vertically
   - Blocks cannot overlap or go beyond board boundaries
   - Only one block can be moved at a time
   - Blocks cannot pass through other blocks

3. Block Types:
   - Cao Cao: 2x2 large block, needs to reach the exit
   - Guan Yu: 1x2 horizontal block, can move horizontally
   - Zhang Fei: 1x2 horizontal block, can move horizontally
   - Zhao Yun: 1x2 horizontal block, can move horizontally
   - Ma Chao: 1x2 horizontal block, can move horizontally
   - Huang Zhong: 1x2 horizontal block, can move horizontally
   - Soldiers: 1x1 small blocks, can move freely

4. Win Condition:
   Cao Cao successfully reaches the exit position at the bottom of the board.

5. Game Tips:
   - Observe block movement patterns
   - Plan movement sequence rationally
   - Use soldiers to create movement space
   - Pay attention to block interdependencies";
        }

        /// <summary>
        /// Get controls guide text
        /// </summary>
        private string GetControlsText()
        {
            return @"Controls Guide:

1. Mouse Operations:
   - Click to select block: Left-click to select the block to move
   - Drag to move: Hold left button and drag block to target position
   - Cancel selection: Click on empty area

2. Keyboard Operations:
   - Arrow keys: Move selected block
   - Space bar: Select/deselect block
   - ESC key: Cancel current selection
   - Ctrl+Z: Undo last move
   - Ctrl+Y: Redo last move

3. Menu Operations:
   - New Game: Start a new game
   - Save Game: Save current game progress
   - Load Game: Load saved game
   - Return to Main Menu: Return to main interface

4. Interface Description:
   - Left side: Game board
   - Top right: Game information (layout, moves, time, hints, status)
   - Bottom right: Control buttons

5. Game Status:
   - Not Started: Game has not started
   - Playing: Currently playing
   - Paused: Game paused
   - Won: Successfully completed game
   - Lost: Game failed

6. Save Function:
   - Auto Save: Automatically save game progress periodically
   - Manual Save: Manually save game progress
   - Load Save: Continue game from saved progress";
        }

        /// <summary>
        /// Get FAQ text
        /// </summary>
        private string GetFAQText()
        {
            return @"Frequently Asked Questions:

Q: How do I start a game?
A: Click 'Start New Game', select a layout, then begin playing.

Q: How do I move blocks?
A: Click to select a block, then use arrow keys to move, or drag the block directly.

Q: What if I can't complete the game?
A: You can use hint function for help, or restart the game.

Q: How do I save game progress?
A: Click 'Save Game' button, or the game will auto-save.

Q: How do I load previous games?
A: Click 'Load Game', then select the save file to load.

Q: How do I adjust game settings?
A: Click 'Settings' in the main menu to adjust various game options.

Q: What if the game gets stuck?
A: You can use undo function to go back one step, or restart the game.

Q: How do I view game statistics?
A: Game statistics are automatically recorded and can be viewed in settings.

Q: What layouts are supported?
A: The game includes various classic layouts like 'Heng Dao Li Ma', 'Jiang Yong Cao Ying', etc.

Q: How do I improve my game skills?
A: Practice more, observe block movement patterns, and plan movement sequences rationally.";
        }

        /// <summary>
        /// Get about information text
        /// </summary>
        private string GetAboutText()
        {
            return @"About HuaRongDao Game:

Version Information:
- Version: 1.0.0
- Development Language: C#
- Development Framework: .NET Framework 4.8
- UI Framework: Windows Forms

Game Features:
- Classic HuaRongDao gameplay
- Multiple classic layouts
- Complete game functionality
- User-friendly interface
- Save and statistics functionality

Development Team:
- Development: AI Assistant
- Design: AI Assistant
- Testing: AI Assistant

Copyright Information:
- Copyright (c) 2024
- This software is for learning and entertainment purposes only

Technical Support:
- For issues, please contact the development team
- Suggestions for improvements are welcome

Update Log:
v1.0.0 (2024-01-01)
- Initial version release
- Implemented basic game functionality
- Support for multiple classic layouts
- Added save and statistics functionality";
        }
    }
} 